package zdream.control.foe.mm;

import zdream.control.world.buff.ControlModule;
import zdream.control.world.buff.HealthModule;
import zdream.control.world.buff.JumpModule;
import zdream.control.world.MFoe;
import zdream.control.world.LevelWorld;

import static zdream.control.world.MFoeConstants.*;

/**
 * @author Zdream
 * @since 0.0.1
 */
public class MegaMan extends MFoe {
	public static final String NAME = "MegaMan";

	public static final String PATTERN_CLIMB_TOP_0 = "climb_top_0";
	public static final String PATTERN_CLIMB_TOP_1 = "climb_top_1";
	public static final String PATTERN_SLIDE = "slide";

	public MegaMan(LevelWorld world) {
		super(world);
		this.type = TYPE_LEADER;
		this.side = SIDE_PLAYER;
	}

	@Override
	public String foeName() {
		return NAME;
	}

	@Override
	public void init() {
		createNormalPattern().withRectangle(-0.453125f, 0, 0.90625f, 1.5f).apply();
		createPattern(PATTERN_CLIMB_TOP_0).withRectangle(-0.453125f, 0, 0.90625f, 1.5f);
		createPattern(PATTERN_CLIMB_TOP_1).withRectangle(-0.453125f, 0, 0.90625f, 0.70833f);
		createPattern(PATTERN_SLIDE).withRectangle(-0.58333f, 0, 1.16666f, 0.75f);
		jumpModule = buildJumpModule()
				.setJumpMaxDy(3)
				.defineAsPassiveMode()
				.create();
		healthModule = buildHealthModule()
				.hpMax(28)
				.immuneDuration(1500)
				.doNotDestroyWhenOutside()
				.armorLevelWhenImmune(ARMOR_LEVEL_PLAYER_IMMUNE)
				.create();
		controlModule = ControlModule.builder(this).create();
		addBuff(motionModule = new MegaManMotionModule(this));
		addBuff(weaponModule = new MegaManWeaponModule(this));

		// painter
//		putPainter(mPainter = new MegaManPainter(this));
	}

//	public MegaManPainter mPainter;

	public ControlModule controlModule;
	public JumpModule jumpModule;
	public HealthModule healthModule;
	public MegaManMotionModule motionModule;
	public MegaManWeaponModule weaponModule;

	@Override
	public void submitMotion(float deltaX, float deltaY) {
		motionModule.submitMotion(deltaX, deltaY);
	}
}
